import _ from "../../utils/underscore.js";
var util = require("../../utils/util.js");
var d = require("../../pages/wxParse/wxParse.js");
import { get, lsGetStr, post } from "../../utils/request.js";
import { getType } from "../../utils/data_type.js";
var { getLoginedUser, setTitle, fnLoading, fnHideLoading, fnSuccess, fnFail } = require('../../utils/index')

Component({
  properties: {
    typeId:{
      type:String,
      value:'',
      
    }

  },
  data: {
    content:'',
    title:'',
    typeId:''
  },

  lifetimes: {
    attached: function () { },
    moved: function () { },
    detached: function () { },
  },
  attached() { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready: function () {
    this.setData({
      typeId: this.properties.typeId || ''
    })
  },
  methods: {
    switchSearchType(e) {

    },
    searchInput(e) {
      

    },
    searchListInput(e) {
    },
    
  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show: function () {
      let that = this;
      get({
        path: '/info/detail/' + (that.data.typeId || 979),
      }).then(function(data){
        that.setData({
          detail: data.content,
          title: data.title,
        })
        setTitle(data.title)
          fnHideLoading();
        d.wxParse("article", "html", that.data.detail, that, 0)
      })
      .catch(function () {
        fnHideLoading();
        fnFail('请求错误，请稍后重试~')
      })
     
    },
  },
})